﻿using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace ApplLogic.ApplClasses
{
    [Serializable]
    public class ApplWorker
    {
        private ApplPersonalDetails m_PersonalDetails;
        private DateTime m_StartOfWork;
        private int m_MaxShiftsThatCanGive;


        public ApplWorker()
        {
            m_PersonalDetails = new ApplPersonalDetails();
        }

        public int MaxShiftsThatCanGive
        {
            get { return m_MaxShiftsThatCanGive; }
            set { m_MaxShiftsThatCanGive = value; }
        }

        public DateTime StartOfWork
        {
            get { return m_StartOfWork; }
            set { m_StartOfWork = value; }
        }

        public ApplPersonalDetails PersonalDetails
        {
            get { return m_PersonalDetails; }
            set { m_PersonalDetails = value; }
        }

        public ApplWorker DeepClone()
        {
            MemoryStream ms = new MemoryStream();
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(ms, this);
            ms.Position = 0;
            ApplWorker obj = (ApplWorker)bf.Deserialize(ms);
            ms.Close();
            return obj;
        }

        public override string ToString()
        {
            return
                string.Format("{0} StartOfWork: {1}\n MaxShiftsThatCanGive: {2}", m_PersonalDetails.ToString(),
                              m_StartOfWork, m_MaxShiftsThatCanGive);
        }
    }
}
